package com.lekang.le.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lekang.common.annotation.Log;
import com.lekang.common.core.controller.BaseController;
import com.lekang.common.core.domain.AjaxResult;
import com.lekang.common.enums.BusinessType;
import com.lekang.le.domain.NursingItemPlanBinding;
import com.lekang.le.service.INursingItemPlanBindingService;
import com.lekang.common.utils.poi.ExcelUtil;
import com.lekang.common.core.page.TableDataInfo;

/**
 * 护理项目与护理计划中间Controller
 * 
 * @author yyh
 * @date 2025-10-16
 */
@RestController
@RequestMapping("/le/level_plan")
public class NursingItemPlanBindingController extends BaseController
{
    @Autowired
    private INursingItemPlanBindingService nursingItemPlanBindingService;

    /**
     * 查询护理项目与护理计划中间列表
     */
    @PreAuthorize("@ss.hasPermi('le:level_plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(NursingItemPlanBinding nursingItemPlanBinding)
    {
        startPage();
        List<NursingItemPlanBinding> list = nursingItemPlanBindingService.selectNursingItemPlanBindingList(nursingItemPlanBinding);
//        System.out.println("关联记录查询结果"+list.size());
//        for(NursingItemPlanBinding nn : list){
//            System.out.println(nn);
//        }
        return getDataTable(list);
    }

    /**
     * 导出护理项目与护理计划中间列表
     */
    @PreAuthorize("@ss.hasPermi('le:level_plan:export')")
    @Log(title = "护理项目与护理计划中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NursingItemPlanBinding nursingItemPlanBinding)
    {
        List<NursingItemPlanBinding> list = nursingItemPlanBindingService.selectNursingItemPlanBindingList(nursingItemPlanBinding);
        ExcelUtil<NursingItemPlanBinding> util = new ExcelUtil<NursingItemPlanBinding>(NursingItemPlanBinding.class);
        util.exportExcel(response, list, "护理项目与护理计划中间数据");
    }

    /**
     * 获取护理项目与护理计划中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('le:level_plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(nursingItemPlanBindingService.selectNursingItemPlanBindingById(id));
    }

    /**
     * 新增护理项目与护理计划中间
     */
    @PreAuthorize("@ss.hasPermi('le:level_plan:add')")
    @Log(title = "护理项目与护理计划中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NursingItemPlanBinding nursingItemPlanBinding)
    {
        return toAjax(nursingItemPlanBindingService.insertNursingItemPlanBinding(nursingItemPlanBinding));
    }

    /**
     * 修改护理项目与护理计划中间
     */
    @PreAuthorize("@ss.hasPermi('le:level_plan:edit')")
    @Log(title = "护理项目与护理计划中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NursingItemPlanBinding nursingItemPlanBinding)
    {
        return toAjax(nursingItemPlanBindingService.updateNursingItemPlanBinding(nursingItemPlanBinding));
    }

    /**
     * 删除护理项目与护理计划中间
     */
    @PreAuthorize("@ss.hasPermi('le:level_plan:remove')")
    @Log(title = "护理项目与护理计划中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(nursingItemPlanBindingService.deleteNursingItemPlanBindingByIds(ids));
    }
}
